package com.example.orderservice.controller;

import com.example.orderservice.feign.ProductFeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class OrderController {
    @Resource
    private ProductFeignClient productFeignClient;

    @GetMapping("/orders/user/{userId}")
    public String getOrdersByUserId(@PathVariable("userId") Long userId) {
        return "用户 " + userId + " 的订单列表";
    }

    @GetMapping("/orders/{orderId}/product/{productId}")
    public String getOrderProductInfo(@PathVariable("orderId") Long orderId,
                                     @PathVariable("productId") Long productId) {
        return "订单 " + orderId + " 包含商品: " + productFeignClient.getProductInfo(productId);
    }
}    